clear			all
set 			more off
cd 				"~/Dropbox/Indonesia Migration/" // Specify your root directory here
********************************************************************************
************************* EDUCATION HETEROGENEITY ******************************
********************************************************************************
set				matsize 11000	
use				"Data/Merged", clear
foreach 		var in ed_1_emp_native ed_2_emp_native ed_3_emp_native ed_4_emp_native ///
				ed_1_wage_native ed_2_wage_native ed_3_wage_native ed_4_wage_native ///
				ed_1_SE_native ed_2_SE_native ed_3_SE_native ed_4_SE_native ///
				ed_1_unpaid_native ed_2_unpaid_native ed_3_unpaid_native ed_4_unpaid_native{
replace			prop_`var' = prop_`var' * 100
}
label 			var per_immig_cst_5Y "Population share of new migrants in year t"
label 			var per_immig_cst_5Y_lag "Population share of new migrants in year t-5"

************************** EMPLOYMENT ****************************************
quietly ivreg2	prop_ed_1_emp_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p1
							
quietly ivreg2	prop_ed_2_emp_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p2
				
quietly ivreg2	prop_ed_3_emp_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p3
						
quietly ivreg2	prop_ed_4_emp_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p4
				
coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.6) ciopts(recast(rcap) lcolor(black))) ///
(p1, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-3.4) ciopts(recast(rcap) lcolor(navy))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.6) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-2.4) ciopts(recast(rcap) lcolor(navy))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.6) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-1.4) ciopts(recast(rcap) lcolor(navy))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.6) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-0.2) ciopts(recast(rcap) lcolor(navy))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) /// 
xlabel(-1.5 `" "Less than" "Primary" "' -0.5 "Primary" 0.5 "Secondary" 1.5 "Tertiary", /// 
noticks labsize(small)) title("{bf:Panel A:} Impact of internal migration on employment", size(small)) xsize(8) ysize(8) /// 
xtitle("Multiple instruments using {it:t-10} migration settlement", size(small)) ///
legend(order(2 "New migrants in year {it:t}" 4 "New migrants in year {it:t-5}") size(small)) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T7_emp_edu_mt10.jpg", as(jpg) name("Graph") quality(100) replace
				
				
************************** WAGE NATIVES ****************************************
quietly ivreg2	prop_ed_1_wage_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p1	
							
quietly ivreg2	prop_ed_2_wage_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p2
				
quietly ivreg2	prop_ed_3_wage_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p3
						
quietly ivreg2	prop_ed_4_wage_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p4

coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.6) ciopts(recast(rcap) lcolor(black))) ///
(p1, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-3.4) ciopts(recast(rcap) lcolor(navy))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.6) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-2.4) ciopts(recast(rcap) lcolor(navy))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.6) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-1.4) ciopts(recast(rcap) lcolor(navy))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.6) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-0.2) ciopts(recast(rcap) lcolor(navy))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) /// 
xlabel(-1.5 `" "Less than" "Primary" "' -0.5 "Primary" 0.5 "Secondary" 1.5 "Tertiary", /// 
noticks labsize(small)) title("{bf:Panel B:} Impact of internal migration on wage employment", size(small)) xsize(8) ysize(8) /// 
xtitle("Multiple instruments using {it:t-10} migration settlement", size(small)) ///
legend(order(2 "New migrants in year {it:t}" 4 "New migrants in year {it:t-5}") size(small)) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T7_wage_edu_mt10.jpg", as(jpg) name("Graph") quality(100) replace
				
				
************************** SE NATIVES ****************************************
quietly ivreg2	prop_ed_1_SE_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p1
							
quietly ivreg2	prop_ed_2_SE_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p2
				
quietly ivreg2	prop_ed_3_SE_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p3
						
quietly ivreg2	prop_ed_4_SE_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p4
				
coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.6) ciopts(recast(rcap) lcolor(black))) ///
(p1, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-3.4) ciopts(recast(rcap) lcolor(navy))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.6) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-2.4) ciopts(recast(rcap) lcolor(navy))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.6) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-1.4) ciopts(recast(rcap) lcolor(navy))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.6) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-0.2) ciopts(recast(rcap) lcolor(navy))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) /// 
xlabel(-1.5 `" "Less than" "Primary" "' -0.5 "Primary" 0.5 "Secondary" 1.5 "Tertiary", /// 
noticks labsize(small)) title("{bf:Panel C:} Impact of internal migration on self employment", size(small)) xsize(8) ysize(8) /// 
xtitle("Multiple instruments using {it:t-10} migration settlement", size(small)) ///
legend(order(2 "New migrants in year {it:t}" 4 "New migrants in year {it:t-5}") size(small)) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T7_self_edu_mt10.jpg", as(jpg) name("Graph") quality(100) replace
	
************************** SE NATIVES ****************************************
quietly ivreg2	prop_ed_1_unpaid_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p1	
							
quietly ivreg2	prop_ed_2_unpaid_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p2
				
quietly ivreg2	prop_ed_3_unpaid_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p3
						
quietly ivreg2	prop_ed_4_unpaid_native (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p4

coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.6) ciopts(recast(rcap) lcolor(black))) ///
(p1, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-3.4) ciopts(recast(rcap) lcolor(navy))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.6) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-2.4) ciopts(recast(rcap) lcolor(navy))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.6) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-1.4) ciopts(recast(rcap) lcolor(navy))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.6) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-0.2) ciopts(recast(rcap) lcolor(navy))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) /// 
xlabel(-1.5 `" "Less than" "Primary" "' -0.5 "Primary" 0.5 "Secondary" 1.5 "Tertiary", /// 
noticks labsize(small)) title("{bf:Panel D:} Impact of internal migration on unpaid work", size(small)) xsize(8) ysize(8) /// 
xtitle("Multiple instruments using {it:t-10} migration settlement", size(small)) ///
legend(order(2 "New migrants in year {it:t}" 4 "New migrants in year {it:t-5}") size(small)) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T7_unpaid_edu_mt10.jpg", as(jpg) name("Graph") quality(100) replace






















